<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>制定工序物料设计单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../css/public.css" media="all">
</head>
<body>
<div id="addgxwl1">

    <div id="addgxwl" style="display: none;">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend style="    margin-left: 404px;">工序物料设计单</legend>
        </fieldset>

        <form action="" class="layui-form" lay-filter="">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 240px" id="titlepro">制造:</label>
            <table class="layui-table" id="test5" lay-filter="test5">
            </table>

            </div>
            <div class="layui-form-item">
                <div class="layui-input-block" style="    margin-left: 370px;">
                    <button type="button" id="addProduction_process_design" class="layui-btn"  >立即提交</button>
                </div>
            </div>
            <label class="layui-form-label" style="width: 300px; color: red;" id="titlepro1">温馨提示:选择要用的物料时 请打勾当前行</label>

        </form>
    </div>
</div>
<!--添加模态框-->
<div id="">

    <div id="addSupper" style="display: none;">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend style="    margin-left: 404px;">工序物料设计单</legend>
        </fieldset>

        <form action="" class="layui-form" lay-filter="">
            <div class="layui-form-item">
                <label class="layui-form-label" style="    margin-left: 70px;">产品名称 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off"  readonly="readonly" style="  border: 0px;   width: 307px;" class="layui-input" id="product_name" lay-verify="required" name="product_name"
                           placeholder="" type="text">

                </div>
                <label class="layui-form-label" style="    margin-left: 165px;">产品编号 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off"  readonly="readonly" style="  border: 0px;   width: 307px;" class="layui-input" id="product_number" lay-verify="required" name="product_number"
                           placeholder="" type="text">

                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="    margin-left: 70px;">设计人 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off" readonly="readonly"  style="  border: 0 ;  width: 307px;" class="layui-input" id="designer" lay-verify="required" name="designer"
                           placeholder="请输入设计人的名称" type="text">

                </div>
                <label class="layui-form-label" style="    margin-left: 165px;">工序单编号 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off"  readonly="readonly" style="  border: 0px;   width: 307px;" class="layui-input" id="process_design_number" lay-verify="required" name="process_design_number"
                           placeholder="" type="text">

                </div>
                <input autocomplete="off"  style="    width: 307px;" class="layui-input" id="prdouctId" lay-verify="required" name="prdouctId"
                       placeholder="请输入设计人的名称" type="hidden">

            </div>
            <table class="layui-table" id="test3" lay-filter="test3">

            </table>
            <div class="layui-form-item">
                <label class="layui-form-label" style="    margin-left: 70px;">审核人 :</label>
                <div class="layui-input-inline">
                    <input autocomplete="off"  readonly="readonly" style=" border: 0;    width: 307px;" class="layui-input" id="auditor_name" lay-verify="required" name="auditor_name"
                           placeholder="" type="text">

                </div>
                <label class="layui-form-label" style="        margin-left: 137px;">审核时间 :</label>
                <div class="layui-input-inline">
                    <input  style="   border: 0;  width: 307px;" class="layui-input" id="registration" lay-verify="required" name="registration"
                            placeholder="" type="text">

                </div>

            </div>


        </form>
    </div>
</div>
<blockquote class="layui-elem-quote news_search" style=" border-left: 0px solid #009688;">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" id="complain_search">
            建档时间:
            <div class="layui-input-inline">
                <input type="text" name="date" id="date" autocomplete="off" class="layui-input">


            </div>至
            <div class="layui-input-inline">
                <input type="text" name="date1" id="date1" autocomplete="off" class="layui-input">


            </div>
            <button id="search" class="layui-btn" lay-submit
                    lay-filter="provinceSearch">
                <i class="layui-icon">&#xe615;</i>
            </button>
        </form>
    </div>
    <table class="layui-hide" id="complainTable" lay-filter="complainList"></table>
</blockquote>

<script type="text/html" id="complain_toolbar">
    <div class="layui-btn-container">
    </div>


</script>
<script type="text/html" id="barDemo2">
    <a class="layui-btn layui-btn-xs" lay-event="edit">查看</a>
</script>
<script type="text/html" id="barDemo3">
    <a class="layui-btn layui-btn-xs" id="shejiD" lay-event="edit">设计</a>

</script>

<script type="text/html" id="barDemo4">
    <input type="text" style="    width: 50px; " class="numberText" />

</script>
<script type="text/html" id="barDemo">

</script>

<script src="../../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="../../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="../../../lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
<script src="../../../lib/common/jquery.cookie.min.js" charset="utf-8"></script>
<script src="../../../lib/common/common.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

<script type="text/javascript" >

    layui.use(['table','layer','form','laypage'], function(){
        var table = layui.table,
            layer = layui.layer,
            form = layui.form,
            laypage = layui.laypage;

        var tableIns =  table.render({
            id:"provinceReload"
            ,elem: '#complainTable'
            ,url:'http://localhost:8003/process_design/getAllProcess_design'
            ,page: true
            ,toolbar: '#complain_toolbar'
            ,cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'id', title: 'ID',  hide:true}
                , {field: 'process_design_number', title: '工序设计单编号', width: 300,},
                {field: 'product_number', title: '产品编号', width: 300, }
                ,  {field: 'product_name', title: '产品名称', width: 300,},
                {field: 'designer', title: '设计人', width: 300,},
                {field: 'registration', title: '登记时间', width: 300,}
                ,{fixed: 'right', width: 100, align:'center', toolbar: '#barDemo2'}
            ]],data: [{

            }, ]

            ,limits: [5,10,20,50]
        });






        table.on('tool(complainList)', function(obj) {
            var data = obj.data;
            json = JSON.stringify(data);
            switch(obj.event) {
                case 'detail':
                    break;
                case 'edit':
                    $("#sjdId").val(data.product_number);
                    $("#shdId").val(data.process_design_number)
                    table.render({
                        elem: '#test3',
                        url:'http://localhost:8003/designprocess/getAllDid?design_id='+data.product_number,
                        height:150
                        ,cols: [[
                            {field:'id', width:70, title: '序号', },
                            {field:'process_name', width:100, title: '工序名称', }
                            ,{field:'process_id', width:100, title: '工序编号'}
                            ,{field:'process_describe', width:100, title: '工序描述', }
                            ,{field:'process_time_gs', width:100, title: '工时数', }
                            ,{field:'process_time_unitdw', title: '工时单位', width: 120, }
                            ,{field:'process_time_cost', width:150, title: '单位工时成本'}
                            ,{field:'process_subtotal', width:150, title: '工时成本小计', }
                            ,{fixed: 'right', width: 100, align:'center', toolbar: '#barDemo3'}

                        ]],


                    });

                    $("#process_design_number").val(data.process_design_number);
                    $("#product_name").val(data.product_name);
                    $("#product_number").val(data.product_number);
                    $("#designer").val(data.designer);
                    $("#registration").val(data.registration);
                    $("#auditor_name").val(data.auditor_name);

                    layer.open({
                        maxmin: true,
                        type: 1,//类型 信息
                        area: ['1000px', '600px'],//定义宽和高
                        title: '工序物料设计单',//题目
                        shadeClose: false,//点击遮罩层关闭
                        content: $('#addSupper')//打开的模态框

                    });
                    break;

            }
        });



        //监听提交
        form.on('submit(supperSub)', function(data){
            var edC=  $("#edidId").val();
            if(edC==1){
                $.ajax({
                    url:'http://127.0.0.1:8005/supper/updateSupperById',
                    data:data.field,
                    success: function (data) {
                        layer.msg("提交成功")
                    }
                })
            }
            if(edC!=1){
                $.ajax({
                    url:'http://127.0.0.1:8005/supper/insertSupper',
                    data:data.field,
                    success: function (data) {
                        layer.msg("提交成功")
                    }
                })
                return;
            }
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            })






        });


        form.render();
        form.on('submit(provinceSearch)', function(data) {
            var formData = data.field;
            var serviceCode = formData.serviceCode,
                compOrder = formData.compOrder,
                compType = formData.compType,
                complainState = formData.complainState;
            table.reload('provinceReload', {
                page: {
                    curr: 1
                },

                url: 'http://127.0.0.1:8005/supper/sellName?name='+formData.name,
            });
            return false;
        });

    });
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });





        //监听提交
        form.on('submit(demo1)', function(data){
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            })
            return false;
        });

        //表单赋值
        layui.$('#LAY-component-form-setval').on('click', function(){
            form.val('example', {
                "username": "贤心" // "name": "value"
                ,"password": "123456"
                ,"interest": 1
                ,"like[write]": true //复选框选中状态
                ,"close": true //开关状态
                ,"sex": "女"
                ,"desc": "我爱 layui"
            });
        });



    });
    layui.use('table', function(){
        var table = layui.table;
        var AddData=[
        ];
        //表单取值
        layui.$('#addProduction_process_design').on('click', function(){



            var checkStatus = table.checkStatus('test5')
                , data = checkStatus.data;
            var ids=$.map(data,function(d){return d.materialnum;});


            var delIndex = layer.confirm('确定提交吗,提交后不可做更改请仔细检查', function (delIndex) {

            })
        });
        table.on('tool(test3)', function(obj){
            var data = obj.data;
            //console.log(obj)
            if(obj.event == 'edit'){
              var productNameA=$("#product_name").val();
              var product_number =$("#product_number").val();
                    $("#titlepro").text("制造"+productNameA+"产品,供选择的物料清单如下")
                table.render({
                    elem: '#test5',
                    url:'http://localhost:8002/material_archives/selectByproId2?productId='+product_number,
                    height:150
                    ,cols: [[
                        {type: 'checkbox', fixed: 'left'},
                        {field:'id', width:100, title: '序号', },
                        {field:'materialid', width:170, align:'center',title: '物料编号', }
                        ,{field:'materialname', width:100,align:'center' ,title: '物料名称'}
                        ,{field:'materialremark', width:150,align:'center', title: '描述', }
                        ,{field:'materialunit', width:170,align:'center', title: '单位', },
                        ,{field:'materialnum', width:80, align:'center', title: '可用数量',templet: function(d){

                    return '<span class="kysl" style="color: #c00;">'+ d.materialnum +'</span>'

                }},



                    ]],


                });

                layer.open({
                    maxmin: true,
                    type: 1,//类型 信息
                    area: ['1000px', '500px'],//定义宽和高
                    title: '工序物料设计单',//题目
                    shadeClose: false,//点击遮罩层关闭
                    content: $('#addgxwl')//打开的模态框

                });

            }
            if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    console.log(index)
                    AddData.splice($.inArray(index,AddData),1);
                    obj.del();
                    layer.close(index);
                });
            }
        });

        //  form.on('submit(test-submit-add)', function (data) {
        //      table.cache['test3'].push(data.field);
        //     table.reload('test3', { data: table.cache['test3']});


        //    });
        //监听行工具事件

        //监听单元格编辑
        table.on('edit(test3)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            //   layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
        });

    });
</script>


</body>
</html>
